def solution(n: int, H: int, A: int, h: list, a: list) -> int:
    # 首先筛选出所有可以被击败的怪物
    candidates = []
    for i in range(n):
        if h[i] < H and a[i] < A:
            candidates.append((h[i], a[i]))

    if not candidates:
        return 0

    # 初始化动态规划数组，每个元素至少可以单独构成序列
    dp = [1] * len(candidates)

    # 动态规划求解最长递增子序列
    for i in range(1, len(candidates)):
        for j in range(i):
            if candidates[i][0] > candidates[j][0] and candidates[i][1] > candidates[j][1]:
                dp[i] = max(dp[i], dp[j] + 1)

    return max(dp)


if __name__ == '__main__':
    print(solution(3, 4, 5, [1, 2, 3], [3, 2, 1]) == 1)
    print(solution(5, 10, 10, [6, 9, 12, 4, 7], [8, 9, 10, 2, 5]) == 2)
    print(solution(4, 20, 25, [10, 15, 18, 22], [12, 18, 20, 26]) == 3)
    print(solution(13, 8, 7, [8, 4, 1, 5, 11, 8, 8, 8, 3, 2, 13, 1, 16],
                   [16, 7, 6, 7, 8, 1, 9, 14, 14, 3, 12, 14, 11]) == 1)